Page({

  /**
   * 页面的初始数据
   */
  data: {
    seat: '',
    maxLength: 50,
    currentLength: 0
  },
  save() {
    this.setData({
      seat: this.data.seat.trim()
    });
    let pages = getCurrentPages(), prevPage = pages[pages.length - 2];
    prevPage.toggle('act.seat', this.data.seat);
    wx.navigateBack({
      delta: 1
    })
  },
  seatInput(e) {
    var seat = e.detail.value, currentLength = e.detail.value.length;
    if (currentLength > this.data.maxLength) {
      wx.showToast({
        title: '输入文字数量已达到上限',
        icon: 'none',
        duration: 2000
      })
      return this.data.seat;
    }
    this.setData({
      seat: seat,
      currentLength: currentLength
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.seat && options.seat != '') {
      this.setData({
        seat: options.seat,
        currentLength: options.seat.length
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  }
})